﻿'Bram Debouvere
Option Strict On

Imports Gift.BL

Public Class frmPersonDetails

    Private _person As Person
    Private _facturation As Facturation

    Public Property Person As Person
        Get
            Return _person
        End Get
        Set(ByVal Value As Person)
            _person = Value
            _facturation = Facturation.getFacturationForPerson(_person, frmMain.dbh)
            txtAdres1.Text = _facturation.AdresLijn1
            txtAdres2.Text = _facturation.AdresLijn2
            txtBedrijfsnaam.Text = _facturation.BedrijfsNaam
            txtLand.Text = _facturation.Land
            txtPostcode.Text = _facturation.PostCode
            txtPlaats.Text = _facturation.Plaats
        End Set
    End Property


    Private Sub frmPersonDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnSaveFacturatiegegevens_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveFacturatiegegevens.Click
        _facturation.AdresLijn1 = txtAdres1.Text
        _facturation.AdresLijn2 = txtAdres2.Text
        _facturation.BedrijfsNaam = txtBedrijfsnaam.Text
        _facturation.Land = txtLand.Text
        _facturation.Plaats = txtPlaats.Text
        _facturation.PostCode = txtPostcode.Text
        Facturation.updateFacturation(_facturation, frmMain.dbh)
        MessageBox.Show("De facturatiegegevens zijn opgeslagen", "Facturatiegegevens : " & _person.Naam & " " & _person.Voornaam, MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    
    Private Sub btnBestellingen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBestellingen.Click
        'show orders for person
        Dim frm As frmOrders = DirectCast(frmMain.showOrderForm(), frmOrders)
        frm.flvOrders.FilterText = _person.Naam & " " & _person.Voornaam
    End Sub

    Private Sub btnLijsten_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLijsten.Click
        'show giftlists for person
        Dim frm As frmGiftLists = DirectCast(frmMain.showGiftListForm(), frmGiftLists)
        frm.flvGeschenkenLijsten.FilterText = _person.Naam & " " & _person.Voornaam

    End Sub
End Class